package cn.bonoon.kernel.web.views;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import cn.bonoon.kernel.util.StringHelper;

public class ExcelColumn {
	public ExcelColumn() {
	}

	public ExcelColumn(String title, String property) {
		this.title = title;
		this.setProperty(property);
	}

	private String title;
	private String property;
	/**
	 * 如果为日期格式,请提供格式化字符串.
	 */
	private String format = StringHelper.DEFAULT_DATETIME_FORMAT;
	
	private String footFormula;
	private String formula;
	
	/**
	 * 该项是否是表达式,如果是,则该项是用表达式来计算的
	 * @return
	 */
	public boolean isFormula(){
		return StringHelper.isNotEmpty(formula);
	}

	public final String getTitle() {
		return title;
	}

	public final void setTitle(String title) {
		this.title = title;
	}

	public void setProperty(String property) {
		this.property = property;
	}

	public String getProperty() {
		return property;
	}

	public String getValue(Object obj) {
		return null;
	}

	/**
	 * 提供格式化日期格式的方法
	 * 
	 * @param date
	 * @return
	 */
	public String formatDate(Date date, Locale locale) {
		return new SimpleDateFormat(format, locale).format(date);
	}

	public void setFormula(String formula) {
		this.formula = formula;
	}

	public String getFormula() {
		return formula;
	}

	public void setFootFormula(String footFormula) {
		this.footFormula = footFormula;
	}

	public String getFootFormula() {
		return footFormula;
	}
}
